﻿using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Windows.Forms;

namespace Common.Components
{
    public class PropertyTextBoxColumn : DataGridColumnStyle
    {
        public Font Font { get; set; }

        public PropertyTextBoxColumn(string name, string property)
        {

        }

        //protected override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight)
        //{
        //    DataGrid dgOwner = base.m_dgOwner;
        //    if ((dgOwner == null) && (base.m_tabstyOwner != null))
        //    {
        //        dgOwner = base.m_tabstyOwner.m_dgOwner;
        //    }
        //    if (dgOwner != null)
        //    {
        //        g.FillRectangle(backBrush, bounds);
        //        bounds.Inflate(-DataGrid.v_nDefaultTextInset, -DataGrid.v_nDefaultTextInset);
        //        RectangleF layoutRectangle = new RectangleF((float)bounds.X, (float)bounds.Y, (float)bounds.Width, (float)bounds.Height);
        //        string s = (string)Formatter.FormatObject(this.PropertyDescriptor.GetValue(source.List[rowNum]), typeof(string), null, null, this.Format, this.FormatInfo, this.NullText, DBNull.Value);
        //        g.DrawString(s, dgOwner.Font, foreBrush, layoutRectangle);
        //    }
        //}



        //    protected internal override  Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight)
        //    {
        //        string[] properties = MappingName.Split(".");
        //        object dataValue = source.List[rowNum];

        //        foreach (string property in properties)
        //        {
        //            PropertyInfo prop = dataValue.GetType().GetProperty(property);
        //            dataValue = prop.GetValue(dataValue, null);
        //        }
        //        DataGrid dgOwner = base.m_dgOwner;
        //if ((dgOwner == null) && (base.m_tabstyOwner != null))
        //{
        //    dgOwner = base.m_tabstyOwner.m_dgOwner;
        //}
        //if (dgOwner != null)
        //{


        //        //object dataValue = source.List[rowNum];
        //        //PropertyInfo property = source.List[rowNum].GetType().GetProperty(_nameData);
        //        //object propValue = property.GetValue(dataValue, null);
        //        //property = propValue.GetType().GetProperty(_property);
        //        //propValue = property.GetValue(propValue, null);

        //        g.FillRectangle(backBrush, bounds);
        //        RectangleF layoutRectangle = new RectangleF((float) bounds.X, (float) bounds.Y, (float) bounds.Width,
        //                                                    (float) bounds.Height);
        //        g.DrawString(dataValue.ToString(), Font, foreBrush, layoutRectangle);
        //    }
        //}
    }
}
